package com.zjdiepu.www.manage.view;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.commpent.ViewScopeControllerHelper;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.dh.IDhLoanAfterService;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.response.YwBusinessDetail;
import com.zjdiepu.www.util.ExceptionHelper;

/**
 * 贷后信息登记Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年05月10日 14时56分<br/>
 * @since 1.0<br/>
 */
@Controller
@RequestMapping(value= "DhLoanAfterViewController", produces="text/html;charset=UTF-8")
@Api(tags = {"贷后信息登记"}, produces="text/html;charset=UTF-8")
public class DhLoanAfterViewController extends BaseController {
    @Resource
    private IDhLoanAfterService dhLoanAfterService;
    @Resource
    private ViewScopeControllerHelper viewScopeControllerHelper;
    @Resource
    private ICachedDictionaryService cachedDictionaryService;
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: loanAfterDetail  <br/>
     * @Description: 贷后信息登记详情 <br/>
     * @param model
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "贷后信息登记详情", response = Boolean.class, httpMethod="GET", tags={"贷后信息登记"})
    @RequestMapping(value = "loanAfterDetail", method = RequestMethod.GET)
    public String loanAfterDetail(Model model, String id) {
    	if (StringUtils.isBlank(id)) {
			ExceptionHelper.thow(ResultFlagType.PARAM_EMPTY);
		}
    	//下拉选项
    	model.addAttribute("expressCompanyType", cachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.EXPRESS_COMPANY,"请选择..."));
    	
    	viewScopeControllerHelper.preparedNowTime(model);
    	YwBusinessDetail ywBusinessDetail = viewScopeControllerHelper.preparedBusiness(id, model);
    	YwBusinessCar car = viewScopeControllerHelper.preparedCar(id,ywBusinessDetail.getCustomerId(), model);
    	if(car != null) {
    		viewScopeControllerHelper.preparedLoan(id, car.getId(), model, car.getCarType());
    	}
    	viewScopeControllerHelper.preparedLoanAfter(id, ywBusinessDetail.getCustomerId(), model);
    	
    	return "system/loanAfter/loanAfterDetail";
    }
}
